<template>
  <el-card class="chart-card" shadow="hover">
    <template #header>
      <div class="chart-header">
        <div class="chart-title">
          <i :class="icon"></i>
          <span>{{ title }}</span>
        </div>
        <div class="chart-tools">
          <slot name="tools"></slot>
        </div>
      </div>
    </template>
    <div class="chart-container" :id="chartId" :style="{ height: `${height}px` }"></div>
  </el-card>
</template>

<script lang="ts">
import { defineComponent } from 'vue'

export default defineComponent({
  name: 'ChartCard',
  props: {
    title: {
      type: String,
      required: true
    },
    icon: {
      type: String,
      default: 'fa fa-chart-bar'
    },
    chartId: {
      type: String,
      required: true
    },
    height: {
      type: Number,
      default: 300
    }
  }
})
</script>

<style scoped lang="scss">
.chart-card {
  margin-bottom: 0;
  
  .chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    
    .chart-title {
      display: flex;
      align-items: center;
      
      i {
        margin-right: 8px;
        font-size: 16px;
      }
      
      span {
        font-size: 15px;
        font-weight: 500;
      }
    }
  }
  
  .chart-container {
    width: 100%;
  }
}
</style> 